package com.siysoft.tc.update.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.siysoft.tc.base.bean.to.User;
import com.siysoft.tc.update.service.IUpdateService;
import com.tc.base.dao.BaseDAO;

@Service
public class UpdateServiceImpl implements IUpdateService{
	@Autowired
	BaseDAO baseDao;

	@Override
	public String student(Integer id, String name, String school,
			String grade, String student_id, String telephone, String email) {
		// TODO Auto-generated method stub
		User user = (User)baseDao.findById(User.class, id);
		if(user.getUser_type() == 1){
			return "error!";
		}
		else{
			System.out.println("bbbbbbbbb" + id+name+school+grade+student_id+telephone+email);
			user.setUser_name(name);
			user.setUser_school(school);
			user.setUser_grade(grade);
			user.setUser_student_id(student_id);
			user.setUser_telephone(telephone);
			user.setUser_email(email);
			baseDao.saveOrupdate(user);
			return "success for update";
		}
	}

	@Override
	public String teacher(Integer id, String name, String grade, String telephone,
			Integer wage, String description) {
		// TODO Auto-generated method stub
		User user = (User)baseDao.findById(User.class, id);
		if(user.getUser_type() == 0){
			return "error!";
		}
		else{
			user.setUser_name(name);
			user.setUser_grade(grade);
			user.setUser_telephone(telephone);
			user.setTeacher_wage(wage);
			user.setTeacher_introduce(description);
			baseDao.update(user);
			return "success for update";
		}
	}

	@Override
	public Integer classroom(Integer id, String number, String lecture,
			Integer max_size, Long time, Integer period, String goal,
			Integer wage, Integer bonus, Integer ispublic) {
		// TODO Auto-generated method stub
		return null;
	}

}
